package com.linkwedo.saas.project;

import java.util.List;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.domain.Target;
import com.linkwedo.saas.domain.Task;
import com.linkwedo.saas.domain.member.User;

public class TargetService {
	private TargetDao targetDao;

	public TargetDao getTargetDao() {
		return targetDao;
	}

	public void setTargetDao(TargetDao targetDao) {
		this.targetDao = targetDao;
	}

	public Target getTarget(Target target) {
		List<Target> uList = getTargetDao().findByExample(target);
		return uList.get(0);
	}
	public Target getTargetById(Integer targetId) {
		Target target= (Target)getTargetDao().findByProperty("id",targetId).get(0);
		return target;
	}
	public void save(Target transientInstance) {		
		try {
			getTargetDao().save(transientInstance);		
		} catch (RuntimeException re) {			
			throw re;
		}
	}
	
	public List findAll() {		
		try {
			return getTargetDao().findAll();
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	
	public List findByProjectID(Integer projectId) {		
		try {
			return getTargetDao().findByProjectId(projectId);
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	public void deleteById(Integer pid) {		
		try {
			Target transientInstance = getTargetDao().findById(pid);
			transientInstance.setId(pid);
			getTargetDao().delete(transientInstance);		
		} catch (RuntimeException re) {			
			throw re;
		}
	}
	
}
